package com.cms.admin.service.common.impl;

import com.cms.admin.mapper.GoodsListMapper;
import com.cms.admin.model.GoodsList;
import com.cms.admin.model.GoodsListExt;
import com.cms.admin.model.PageBean;
import com.cms.admin.service.common.GoodsListService;

import java.util.List;

/**
 * Created by Faroe on 17/5/8.
 */

public class GoodsListServiceImpl implements GoodsListService {

    private GoodsListMapper goodsListMapper;

    @Override
    public List<GoodsListExt> queryGoodsList(PageBean page, GoodsListExt example) {
        int count=getRowCount(example);
        page.setAllRow(count);
        example.setOffset(page.getOffset());
        example.setPageSize(page.getPageSize());
        return goodsListMapper.selectByCondition(example);
    }


    @Override
    public int addGoods(GoodsList record){
        return goodsListMapper.insert(record);
    }


    @Override

    public int updateGoods(GoodsList record){
        return goodsListMapper.updateByPrimaryKey(record);
    }

    @Override
    public int deleteGoods(Long recid){return goodsListMapper.deleteByPrimaryKey(recid);}

    @Override

    public List<GoodsListExt> queryAllGoodsList() {
        return goodsListMapper.selectAll();
    }

    @Override

    public int getRowCount(GoodsListExt example) {
        return goodsListMapper.countByCondition(example);
    }

    public GoodsListMapper getGoodsListMapper() {
        return goodsListMapper;
    }

    public void setGoodsListMapper(GoodsListMapper goodsListMapper) {
        this.goodsListMapper = goodsListMapper;
    }
}
